<?php
if (isset($_POST['vybrat'])) {
    $_SESSION['veduci'] = $_POST['oddelenie'];
}
?>

<form style="margin: 10px 0; border-bottom: 1px solid gray; padding-bottom: 2px;" action="home.php?akc=4" method="post">
    <select name="oddelenie">
        <?php
        $odd_s = "SELECT * FROM oddelenie ORDER BY nazov ASC";
        $odd_q = MySQL_Query ($odd_s);
        while ($odd = MySQL_Fetch_Array($odd_q)) {
            if ($_SESSION['veduci']==$odd['id'])
                echo '<option value="'.$odd['id'].'" selected>'.$odd['nazov'].'</option>';
            else
                echo '<option value="'.$odd['id'].'">'.$odd['nazov'].'</option>';
        }
        ?>
        }
    </select>
    <input name="vybrat" value="Vybrať oddelenie" type="submit" />
</form>

<?php

if (isset($_SESSION['veduci'])){
    $veduci_oddelenia = $_SESSION['veduci'];
    include('obycZam.php');
} else {
    $veduci_oddelenia = -1;
    echo 'Vyberte oddelenie.';
}


?>